﻿/*
 * MIT License
 *Copyright (c) 2021 咖啡与网络(java-and-net)
 *
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using CoreShop.Model;
using CoreShop.Repository;
using SqlSugar;

namespace CoreShop.Services
{
    /// <summary>
    /// 商品分类信息接口实现类
    /// </summary>
    public class corecmspaymentsService : Repository<corecmspayments>, IcorecmspaymentsService
    {
        #region 支付信息

        public bool InsertAsync(corecmspayments entity)
        {
            return base.Change<corecmspayments>().Insert(entity);
        }

        /// <summary>
        /// 更新商品分类 删除标志
        /// </summary>
        /// <param name="custo"></param>
        /// <returns></returns>
        public bool UpdDataInfo(corecmspayments sysPayment)
        {
            var bl = base.Update(a => new corecmspayments()
            {
                code = sysPayment.code,
                name = sysPayment.name,
                memo = sysPayment.memo,
                isEnable = sysPayment.isEnable,
            }, a => a.id == sysPayment.id);
            return bl;
        }
    

        /// <summary>
        /// 查询所有商品分类信息
        /// </summary>
        /// <returns></returns>
        public List<corecmspayments> SelectDataAll()
        {
            //查询出所有商品分类信息
            List<corecmspayments> sysPayments = new List<corecmspayments>();
            var where = Expressionable.Create<corecmspayments>();
            where = where.And(a => a.id > 0);
            sysPayments = base.AsQueryable().WhereIF(true, where.ToExpression())
                    .OrderBy(a => a.id).ToList();

            return sysPayments;
        }

        /// <summary>
        /// 根据商品分类Id查询商品分类信息
        /// </summary>
        /// <param name="CustoNo"></param>
        /// <returns></returns>
        public corecmspayments SelectDataById(Int32 id)
        {
            corecmspayments sysPayment = base.GetSingle(a => a.id == id);
            return sysPayment;
        }

        #endregion
    }
}
